package com.yxq.mdt.app.modules.auction.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.auction.bean.AuctionList;
import com.yxq.mdt.app.modules.auction.bean.AuctionProfitBean;
import com.yxq.mdt.app.modules.auction.bean.AuctionTxBean;
import com.yxq.mdt.app.modules.auction.bean.MyTeamFansBean;
import com.yxq.mdt.app.modules.auction.model.AuctionModel;
import com.yxq.mdt.app.modules.login.bean.UserBean;
import com.yxq.mdt.app.modules.login.model.LoginModel;
import com.yxq.mdt.app.modules.login.presenter.ILoginContract;
import com.yxq.mdt.app.modules.personal.bean.MainPersonTokenBean;
import com.yxq.mdt.app.modules.personal.bean.MainPersonalImNumber;
import com.yxq.mdt.app.modules.personal.model.MainPersonalApi;
import com.yxq.mdt.app.modules.socialcontact.bean.MainSocialContactRecommendBean;
import com.yxq.mdt.app.net.ApiModel;
import com.yxq.mdt.app.net.BaseObserver;
import com.yxq.mdt.app.net.RetrofitFactory;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * ================================================
 *
 * @function 登录
 * Created by yd on 2019/03/26.
 * ================================================
 */
public class AuctionPresenter extends BasePresenter<AuctionContract.View, AuctionModel> implements AuctionContract.Presenter {

    public AuctionPresenter(AuctionContract.View view, AuctionModel model) {
        super(view, model);
    }

    @Override
    public void getAuctionListByType(int type, int pageNum, int pageSize) {
        mBaseModel.getAuctionListByType(type, pageNum, pageSize, new ApiModel.CommonCallback<AuctionList>() {
            @Override
            public void onSuccess(AuctionList myTeamFansBean) {
                mRootView.onLoadAuctionListByTypeSuccess(myTeamFansBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadAuctionListByTypeFailed();
            }
        });
    }

    @Override
    public void getUserCashList(String pageNum, String pageSize) {
        mBaseModel.getUserCashList(pageNum, pageSize, new ApiModel.CommonCallback<AuctionProfitBean>() {
            @Override
            public void onSuccess(AuctionProfitBean auctionProfitBean) {
                mRootView.onLoadUserCashListSuccess(auctionProfitBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadUserCashListFailed();
            }
        });
    }

    @Override
    public void getUserIncomeList(int pageSize, int pageNum, int isEntry) {
        mBaseModel.getUserIncomeList(pageSize, pageNum, isEntry == -1 ? null : isEntry + "", new ApiModel.CommonCallback<AuctionTxBean>() {
            @Override
            public void onSuccess(AuctionTxBean auctionTxBean) {
                mRootView.onLoadUserIncomeListSuccess(auctionTxBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadUserIncomeListFailed();
            }
        });
    }

    public void addUserCash(String drillNo, String userName, String drillAmount, String userPhone) {
        mBaseModel.addUserCash(drillNo, userName, drillAmount, userPhone, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                mRootView.onLoadAddUserCashSuccess(result);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadAddUserCashFailed(errMsg);
            }
        });
    }
}
